package csxXiti.xiti3;

/**
 * @author WuYongheng
 * @date 2021/11/23
 * @description
 */

//接口，方便下面实现
interface SpeakEnglish {
    //说英语
    void speak();
}

//抽象类人
abstract class Persion {
    private String name;//姓名
    private int age;//年龄
    //无参构造
    public Persion() {
    }
    //有参构造
    public Persion(String name, int age) {
        this.name = name;
        this.age = age;
    }
    //吃饭的抽象方法
    public abstract void eat();
    //展示姓名和年龄
    public void show() {
        System.out.printf("姓名：%s\t年龄：%d",name,age);
        System.out.println();
    }
    //成员变量
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
}


//子类继承父类
abstract class Player extends Persion{
    //无参构造
    public Player() {
        super();
    }
    //有参构造方法
    public Player(String name,int age) {
        super();
    }
    //运动员学习的抽象类
    public abstract void student();
}


//子类继承
abstract class Coach extends Persion {
    //无参构造
    public Coach() {
        super();
    }
    //有参构造方法
    public Coach(String name,int age) {
        super();
    }
    //教练教授的学习方法
    public abstract void teacher();
}


//乒乓球相关人员需要说英语s
//具体类
class PingpangPlayar extends Player implements SpeakEnglish {

    public void student() {
        System.out.println("乒乓球运动员要练习发球和接球技巧");
    }

    public void eat() {
        System.out.println("乒乓运动员吃清淡的饭菜");
    }
    //重写
    public void speak() {
        System.out.println("乒乓球运动员要学习英语");
    }
}


//子类继承
class PingpangCoach extends Coach implements SpeakEnglish {

    public void teacher() {
        System.out.println("乒乓球教练要教导队员发球和接球技巧");
    }

    public void eat() {
        System.out.println("乒乓球教练跟着队员吃清淡的饭菜");
    }

    public void speak() {
        System.out.println("乒乓球教练要学习英语");
    }
}


//子类继承
class BasketballPlayer extends Player {


    public void student() {
        System.out.println("篮球运动员要练习运球和投篮技巧");
    }

    public void eat() {
        System.out.println("篮球运动员要吃高蛋白的饭菜，保持健壮的身体");
    }

}


//子类继承
class BasketballCoach extends Coach {
    public void teacher() {
        System.out.println("篮球教练要跟着队员，要吃高蛋白的饭菜");
    }
    public void eat() {
        System.out.println("篮球教练要教导队员投篮技巧和制定战术");
    }
}



public class xiti3_4 {
    //主函数调用
    public static void main(String[] args) {
        //实例化乒乓球运动员
        PingpangPlayar pp = new PingpangPlayar();//创建对象
        //调用对象方法
        pp.setName("张三");
        pp.setAge(33);
        pp.show();
        pp.eat();
        pp.student();
        pp.speak();

        System.out.println("----------------------");
        //实例化乒乓球教练
        PingpangCoach pc = new PingpangCoach();
        pc.setName("李四");
        pc.setAge(33);
        pc.show();
        pc.eat();
        pc.teacher();
        pc.speak();

        System.out.println("----------------------");
        //实例化篮球运动员
        BasketballPlayer bp = new BasketballPlayer();
        bp.setName("柳五");
        bp.setAge(44);
        bp.show();
        bp.eat();
        bp.student();

        System.out.println("----------------------");
        //实例化篮球教练
        BasketballCoach bc = new BasketballCoach();
        bc.setName("刘六");
        bc.setAge(55);
        bc.show();
        bc.eat();
        bc.teacher();
        System.out.println("qingshuru");
    }}
